<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>焦点学苑</title>
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="webjars/layui/2.5.6/css/layui.css"
	media="all">
<!-- vue -->
<script type="text/javascript"src="https://lib.baomitu.com/vue/2.6.12/vue.min.js"></script>
<!-- axios -->
<script type="text/javascript"src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.min.js"></script>
<script src="js/top.js"></script>
<script src="js/category.js"></script>
</head>
<body>
<div class="head-box" id = "login-btm">
    <div class="head wrap" >
          <div class="logo fl"><a href=""><img src="images/logo.png"></a></div>
          <div class="head-right fr">
             <!--  <div class="head-a fr">
                   <div class="hgt fl"><img src="images/hgt.png">
                         <div class="hgt-top">
                             <input type="text" class="hgt-text">
                         </div>
                   </div>
                   <div class="head-a1 fl"><a href=""><img src="images/tb-a.png"></a></div>
                   <div class="head-a1 fl"><a href=""><img src="images/tb-b.png"></a></div>
                   <div class="head-a3 login-click fl">登录</div>
                   <div class="head-a4 reg-click fl">注册</div>
              
              </div> -->
              <top></top>
              
              <div class="clearfix"></div>
              <div class="nav fr">
                  <ul>
                       <li><a href="index.html">首页</a></li>
                       <li><a href="">文章</a>
                           <category></category>
                       </li>
                       <li><a href="community.html">社区</a></li>
                       <li class="nav-cut"><a href="course.html">课程</a></li>
                       <li><a href="active.html">活动</a></li>
                       <li><a href="contact.html">联系我们</a></li>
                  
                  </ul>
              </div>
              <div class="clearfix"></div>
          </div>
    </div>
</div>
<script>
              var v3 = new Vue({
            	  el:"#login-btm",
              });
              </script>
<br></br><br></br><br></br>            
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>发表新帖</legend>
</fieldset>
<form class="layui-form" action="" method="post">
<!--   <div class="layui-form-item"> -->
<!--     <label class="layui-form-label">发帖人姓名</label> -->
<!--     <div class="layui-input-block"> -->
<!--       <input v-model="post.uname" type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入名字" class="layui-input"> -->
<!--     </div> -->
<!--   </div> -->
  
   <div class="layui-form-item">
   <label class="layui-form-label">标题</label>
   <div class="layui-input-block">
     <input v-model="post.pname" type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请填写标题" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">内容</label>
    <div class="layui-input-block">
      <textarea v-model="post.pcontent" placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
  </div>
  <!--<div class="layui-form-item layui-form-text">
    <label class="layui-form-label">编辑器</label>
    <div class="layui-input-block">
      <textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="LAY_demo_editor"></textarea>
    </div>
  </div>-->
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button type="button" @click="addPost" class="layui-btn" lay-submit="" lay-filter="demo1">发表</button>
      <button type="reset" class="layui-btn layui-btn-primary" onclick="goBack()" >返回</button>
    </div>
  </div>
</form>

<script src="webjars/layui/2.5.6/layui.js" charset="utf-8"></script>

<script>

	
var v = new Vue({
	el : ".layui-form",
	data : {
		post : {
			uname : "",
			pname : "",
			pcontent : "",
			uid : ""
		}
	},
	created(){
		axios.get("getloginUser.s").then(res=>{
			if(res.data!=null){
// 				console.info(res.data);
				this.post.uname=res.data.uname;
				//$("#loginA").hide();
				this.post.uid=res.data.uid;
				
			}
		})
		
	},
	methods : {
		addPost(){
			var params = new URLSearchParams();
			params.append("uname",this.post.uname);
			params.append("pname",this.post.pname);
			params.append("pcontent",this.post.pcontent);
			params.append("uid",this.post.uid);
			axios.post("post/addPost.s",params).then(res=>{
				alert(res.data.msg);
				pname = "";
				pcontent = "";
				console.info("------"+this.post.pname);
				console.info("==="+this.post.pcontent);
			})
		}
	},
	
});

function goBack(){
    history.back();         
};



</script>


</body>
</html>